package cn.hengzq.leetcode.demo1480;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * 1480. 一维数组的动态和
 */
public class Test {
    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4};
        System.out.println(Arrays.stream(Arrays.stream(runningSum(nums)).toArray()).mapToObj(String::valueOf).collect(Collectors.joining(",")));
    }

    public static int[] runningSum(int[] nums) {
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum = sum + nums[i];
            nums[i] = sum;
        }
        return nums;
    }
}
